package com.clk.portfoy.classlib.xml;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.clk.portfoy.classlib.portfoy.AbsDeger;
import com.clk.portfoy.classlib.portfoy.DHisseSenedi;
import com.clk.portfoy.classlib.portfoy.Portfoy;

@XmlRootElement
public class XmlPortfoy {
	@XmlElement
	private List<XmlDeger> degerler = new ArrayList<XmlDeger>();

	// ---------------------------------------------------------------------------------
	public XmlPortfoy() {

	}

	// ---------------------------------------------------------------------------------
	public XmlPortfoy(Portfoy p) {
		List<AbsDeger> degerler = p.getDegerler();
		for (AbsDeger deger : degerler) {
			this.degerler.add(new XmlDeger(deger));
		}
	}

	// ---------------------------------------------------------------------------------
	public Portfoy getPortfoyEqual() {
		Portfoy portfoy = new Portfoy();
		for (XmlDeger deger : degerler) {
			DHisseSenedi senet = new DHisseSenedi();
			senet.setIsim(deger.getIsim());
			senet.setAdet(deger.getAdet());
			senet.setAlisDeger(deger.getAlisDeger());
			senet.setAlisTarihi(deger.getAlisTarihi());
			senet.setGrup(deger.getGrup());
			senet.setHedefDeger(deger.getHedefDeger());
			senet.setIsim(deger.getIsim());
			senet.setRealizeDeger(deger.getSatilanDeger());
			senet.setSatisTarihi(deger.getSatisTarihi());
			portfoy.add(senet);
		}
		return portfoy;
	}
	// ---------------------------------------------------------------------------------
}
